home *** CD-ROM | disk | FTP | other *** search
- // modeldlg.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "modeless.h"
- #include "adderdlg.h"
- #include "modeldlg.h"
-
- #ifdef _debug
- #undef this_file
- static char based_code THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg dialog used for App About
-
- class CAboutDlg : public CDialog
- {
- public:
- CAboutDlg();
-
- // Dialog Data
- //{{AFX_DATA(CAboutDlg)
- enum { IDD = IDD_ABOUTBOX };
- //}}AFX_DATA
-
- // Implementation
- protected:
- virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
- //{{AFX_MSG(CAboutDlg)
- virtual BOOL OnInitDialog();
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
-
- CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
- {
- //{{AFX_DATA_INIT(CAboutDlg)
- //}}AFX_DATA_INIT
- }
-
- void CAboutDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CAboutDlg)
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
- //{{AFX_MSG_MAP(CAboutDlg)
- // No message handlers
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CAboutDlg message handlers
-
- BOOL CAboutDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CenterWindow();
- return TRUE;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CMainDlg dialog
-
- CMainDlg::CMainDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CMainDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CMainDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
- m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
- m_pModeless = NULL;
- }
-
- void CMainDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMainDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
-
- BEGIN_MESSAGE_MAP(CMainDlg, CDialog)
- //{{AFX_MSG_MAP(CMainDlg)
- ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
- ON_WM_QUERYDRAGICON()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- // CMainDlg message handlers
-
- BOOL CMainDlg::OnInitDialog()
- {
- CDialog::OnInitDialog( );
-
- // Add "About..." menu item to system menu.
-
- // IDM_ABOUTBOX must be in the system command range.
- ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
- ASSERT(IDM_ABOUTBOX < 0xF000);
-
- // CMenu* pSysMenu = GetSystemMenu(FALSE);
- // CString strAboutMenu;
- // strAboutMenu.LoadString(IDS_ABOUTBOX);
- // if (!strAboutMenu.IsEmpty())
- // {
- // pSysMenu->AppendMenu(MF_SEPARATOR);
- // pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
- // }
-
- return TRUE; // return TRUE unless you set the focus to a control
- }
-
- void CMainDlg::OnSysCommand(UINT nID, LPARAM lParam)
- {
- if ((nID & 0xFFF0) == IDM_ABOUTBOX)
- {
- CAboutDlg dlgAbout;
- dlgAbout.DoModal();
- }
- else
- {
- CDialog::OnSysCommand(nID, lParam);
- }
- }
-
- // If you add a minimize button to your dialog, you will need the code below
- // to draw the icon. For MFC applications using the document/view model,
- // this is automatically done for you by the framework.
-
- void CMainDlg::OnPaint()
- {
- CDialog::OnPaint();
- }
-
- // The system calls this to obtain the cursor to display while the user drags
- // the minimized window.
- HCURSOR CMainDlg::OnQueryDragIcon()
- {
- return (HCURSOR) m_hIcon;
- }
-
- void CMainDlg::OnOK()
- {
- // if our modeless child isn't already up, create it and display it
- // otherwise, just set focus to it
-
- if (m_pModeless == NULL)
- {
- m_pModeless = new CAdderDialog(this);
- if (m_pModeless->Create() == TRUE)
- GetDlgItem(IDOK)->EnableWindow(FALSE);
- }
- else
- m_pModeless->SetActiveWindow();
- }
-
-
- void CMainDlg::BoxDone()
- {
- // this function is called by the modeless dialog as it terminates
- // just reset our pushbutton to be enabled again.
- // I _don't_ delete the MFC CDialog object because the dialog's own
- // code will do that.
-
- m_pModeless = NULL;
- // don't delete m_pModeless; !
- GetDlgItem(IDOK)->EnableWindow();
- }
-